package sorting;

import java.util.Random;

public class SortingApp {
    
    private static final int LENGTH = 10;

    public static void main(String[] args) {
        //Bubble sorting
        System.out.println("Bubble sorting: ");
        int[] bubbleData = generate(100);
        Sorting bubble = new BubbleSorting(bubbleData);
        bubble.display();
        bubble.sort();
        bubble.display();
        
        System.out.println("Sorted data in order: ");
        bubble.sort();
        bubble.display();
        
        //Selection sorting
        System.out.println("Selection sorting: ");
        int[] selectionData = generate(50);
        Sorting selection = new SelectionSorting(selectionData);
        selection.display();
        selection.sort();
        selection.display();
        
        System.out.println("Sorted data in order: ");
        selection.sort();
        selection.display();
        
        //Insertion Sorting
        System.out.println("Insertion sorting: ");
        int[] insertionData = generate(30);
        Sorting insertionSort = new InsertionSorting(insertionData);
        insertionSort.display();
        insertionSort.sort();
        insertionSort.display();
        
        System.out.println("Sorted data in order: ");
        insertionSort.sort();
        insertionSort.display();
        
    }
    
    private static int[] generate(int seed) {
        int[] datas = new int[LENGTH];
        for (int i = 0; i < LENGTH; i++) {
            Random random = new Random();
            datas[i] = random.nextInt(seed);
        }
        return datas;
    }
}
